package controller

import (
	"github.com/kataras/iris"
	"github.com/kataras/iris/mvc"

	"gitee.com/fx8s/goIrisTest/src/modules/story/usecase"
)

//StoryController
type StoryController struct {
	Ctx           iris.Context
	StoryUsercase usecase.StoryUsercase
}

//GetRegister get
func (c *StoryController) Get() mvc.Result {
	entitys, err := c.StoryUsercase.GetAll()

	if err != nil {
		return mvc.View{
			Name: "index.html",
			Data: iris.Map{"Title": "Stories"},
		}
	}

	return mvc.View{
		Name: "index.html",
		Data: iris.Map{
			"Title":   "Stories",
			"Stories": entitys,
		},
	}
}
